<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j" xmlns:p="http://primefaces.org/ui"
	xmlns:t="http://myfaces.apache.org/tomahawk" template="/pages/template/main-layout.xhtml"
	xmlns:ap="http://aplikata.com/facelets">
	<ui:define name="content">
		<h:panelGrid columns="1" cellpadding="5" width="100%" id="panelGroup">
			<p:accordionPanel id="accPanel" activeIndex="#{evokPatientTherapyArchiveBean.tabIndex}">
				<p:tab title="#{msgs.table_queryresult}" id="archiveList">
					<p:dataTable id="therapyTable" var="tr"
						value="#{evokPatientTherapyArchiveBean.therapyLazyModel}" border="1" rowIndexVar="ri"
						emptyMessage="" currentPageReportTemplate="#{msgs.paginator_currentPage}"
						paginatorTemplate="#{msgs.paginator}" paginator="true" rows="15" paginatorPosition="bottom"
						selectionMode="single" widgetVar="wdgPatientTherapyList">
						<p:ajax event="rowSelect" listener="#{evokPatientTherapyArchiveBean.detailsAction}"
							update=":mainform:panelGroup" />
						<f:facet name="header">
							<p:panelGrid columns="5" cellpadding="4" width="100%"
								columnClasses="width20,width20,width20,width20,width20">
								<h:outputLabel for="startDate" value="#{msgs.patient_therapy_startDate_from}" />
								<p:calendar id="startDate" value="#{evokPatientTherapyArchiveBean.startDateFrom}"
									pattern="dd/MM/yyyy" showOn="button" navigator="true">
									<p:ajax event="dateSelect"
										listener="#{evokPatientTherapyArchiveBean.handleStartDateFromSelect}"
										update="therapyTable" />
								</p:calendar>

								<h:outputLabel for="endDate" value="#{msgs.patient_therapy_startDate_to}" />
								<p:calendar id="endDate" value="#{evokPatientTherapyArchiveBean.startDateTo}"
									pattern="dd/MM/yyyy" showOn="button" navigator="true">
									<p:ajax event="dateSelect"
										listener="#{evokPatientTherapyArchiveBean.handleStartDateToSelect}" update="therapyTable" />
								</p:calendar>

								<p:commandButton actionListener="#{evokPatientTherapyArchiveBean.resetDates}"
									icon="ui-icon-arrowrefresh-1-n" value="#{msgs.button_reset}" update="therapyTable" />
							</p:panelGrid>
						</f:facet>
						<p:columnGroup type="header">
							<p:row>
								<p:column rowspan="2" headerText="#{msgs.table_index}" />
								<p:column colspan="2" headerText="#{msgs.evok_doctor_title}" />
								<p:column rowspan="2" headerText="#{msgs.domain_title}" />
								<p:column rowspan="2" sortBy="#{tr.startDate}" headerText="#{msgs.patient_archive_start}" />
								<p:column rowspan="2" colspan="1" sortBy="#{tr.endDate}">
									<f:facet name="header">
										<h:outputText value="#{msgs.patient_archive_end}" />
									</f:facet>
								</p:column>
								<p:column rowspan="2" headerText="#{msgs.patient_therapy_success}" />
								<p:column rowspan="2" headerText="#{msgs.default_status}" />
								<p:column rowspan="2" headerText="#{msgs.comment_label}" />
							</p:row>
							<p:row>
								<p:column colspan="1" headerText="#{msgs.empl_surname}"
									sortBy="#{tr.creator.userReference.surname}" filterBy="#{tr.creator.userReference.surname}" />
								<p:column colspan="1" headerText="#{msgs.empl_name}"
									sortBy="#{tr.creator.userReference.name}" filterBy="#{tr.creator.userReference.name}" />
							</p:row>
						</p:columnGroup>

						<p:column>
							<h:outputText value="#{ri+1}" />
						</p:column>

						<p:column>
							<h:outputText value="#{tr.creator.userReference.surname}" />
						</p:column>

						<p:column>
							<h:outputText value="#{tr.creator.userReference.name}" />
						</p:column>

						<p:column>
							<h:outputText value="#{tr.creator.domain.name}" />
						</p:column>

						<p:column sortBy="#{tr.startDate}">
							<h:outputText value="#{tr.startDate}">
								<f:converter converterId="dateConverter" />
							</h:outputText>
						</p:column>

						<p:column sortBy="#{tr.endDate}">
							<h:outputText value="#{tr.endDate}">
								<f:converter converterId="dateConverter" />
							</h:outputText>
						</p:column>

						<p:column>
							<h:outputText value="#{tr.success}" converter="enumConverter" enumName="TherapySuccess" />
						</p:column>

						<p:column>
							<h:outputText value="#{tr.status}" converter="enumConverter" enumName="TherapyStatus" />
						</p:column>

						<p:column>
							<p:column>
								<t:htmlTag rendered="#{tr.patientCommentCount>0}" style="float:left;" value="span"
									styleClass="#{tr.patientCommentCount > 0 ? 'ui-icon ui-icon-comment red' : 'ui-icon ui-icon-comment'}" />

								<h:outputText value="&#160;" escape="false" />
								<h:outputText value="#{tr.patientCommentCount}"
									style="#{tr.patientCommentCount &gt; 0 ? 'color:red' : ''}" />
							</p:column>
						</p:column>
					</p:dataTable>
				</p:tab>
				<p:tab title="#{msgs.patient_therapy_title}" id="archiveDetails">
					<p:tabView id="tabviewArchiveTherapy"
						activeIndex="#{evokPatientTherapyArchiveBean.tabDetailIndex}"
						rendered="#{evokPatientTherapyArchiveBean.patientTherapy != null }">
						<p:ajax event="tabChange" listener="#{evokPatientTherapyArchiveBean.onTabChange}"
							update=":mainform:accPanel:therapyTable" />

						<p:tab id="therapyBasicInfo" title="#{msgs.patient_therapy_basic}">
							<ui:include src="/pages/aplikata/evok/doctor/archive/patient_therapy_archive_basic.xhtml" />
						</p:tab>
						<p:tab id="therapyProcessInfo" title="#{msgs.patient_therapy_process}">
							<ap:dynamicCategoryTable value="#{evokPatientTherapyArchiveBean.pnList}" id="therapyprocess"
								readonly="true" />
						</p:tab>
						<p:tab id="reservation" title="#{msgs.patient_reservations}">
							<ui:include
								src="/pages/aplikata/evok/doctor/archive/patient_therapy_archive_reservation.xhtml" />
						</p:tab>
						<p:tab id="qtnaireInfo" title="#{msgs.patient_therapy_qtnaires}">
							<ui:include src="/pages/aplikata/evok/doctor/archive/patient_therapy_archive_qtnaire.xhtml" />
						</p:tab>
						<p:tab id="uploadInfo" title="#{msgs.patient_therapy_attachment}">
							<ui:include src="/pages/aplikata/evok/doctor/archive/patient_therapy_archive_upload.xhtml" />
						</p:tab>
						<p:tab id="therapyServiceInfo" title="#{msgs.therapy_service_plural}">
							<ui:include src="/pages/aplikata/evok/doctor/archive/patient_therapy_archive_service.xhtml" />
						</p:tab>
						<p:tab id="commentInfo"
							title="#{msgs.comment} (#{evokPatientTherapyArchiveBean.unreadComments}) ">
							<ui:include src="/pages/aplikata/evok/doctor/archive/patient_therapy_archive_comment.xhtml" />
						</p:tab>
					</p:tabView>
				</p:tab>
			</p:accordionPanel>
		</h:panelGrid>
	</ui:define>
	<ui:define name="dialog">
		<h:panelGroup id="qtnairePanelGroup">
			<ui:include src="/pages/aplikata/evok/dialog/qtnaire/qtnaire_dialog_show.xhtml" />
		</h:panelGroup>
	</ui:define>
</ui:composition>
